
from WtfEngine import *;
import WtfGui;

# XXX: memory leak here, need to override Destroy/Remove
class CheckBox(WtfGui.LayoutContainer):
	def __init__(self, n, value, font = WtfGui.Font("v_gui_font")):
		WtfGui.LayoutContainer.__init__(self,
			WtfGui.LayoutContainerCreationOptions(), 0);
		
		self.checked = not value;
		self.button = WtfGui.Button(Function(self.Toggle), "x", font);
		
		self.AddChild(self.button);
		self.AddChild(WtfGui.Label(n, font));
		self.Toggle();
	
	def Toggle(self):
		DebugPrint("Toggle");
		self.checked = not self.checked;
		self.button.caption = self.checked and "x" or "";
		